﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using Evoucher.Business.EnBankPaymentService;
using System.Security.Cryptography.X509Certificates;
using System.Net.Security;
using System.Net;

namespace Evoucher.Business.PaymentGateways
{
    public class EnBankPaymentGateway : IPaymentGateway
    {
        public double VerifyTransaction(string RefNum, string MerchantId)
        {
            // Fixing Invalid https problem
            ServicePointManager.ServerCertificateValidationCallback = RemoteCertificateValidationCallback;

            PaymentIF ws = new ChannelFactory<PaymentIF>("EnBankPaymentIFPort").CreateChannel();
            return ws.verifyTransaction(RefNum, MerchantId);
        } 

        public static bool RemoteCertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
        {
            return true;
        }
    }
}
